package com.myzf.ncov.task;

import com.myzf.ncov.get.GetData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 获取数据的定时任务
 *
 * @author limuyi
 * @version V1.0
 * Created by limuyi on 2020-02-01 12:58
 */
@Slf4j
@EnableAsync
@Component
@PropertySource("classpath:application.yml")
public class GetTasks {

    @Autowired
    private GetData getData;

    /**
     * 获取数据肺炎疫情定时任务
     */
    @Async
    @Scheduled(fixedDelayString = "#{1000 * 60 * ${pneumonia.period}}")
    public void getPneumoniaEpidemicSituationTask() {
        log.info("### 获取肺炎疫情数据定时任务开始 ###");
        getData.getPneumoniaEpidemicSituationData();
        log.info("### 获取肺炎疫情数据定时任务结束 ###");
    }

    /**
     * 获取疫情的实时报告定时任务
     */
    /*@Async
    @Scheduled(fixedDelayString = "#{1000 * 60 * ${pneumonia.period}}")
    public void getSituationRealTimeReportTask() {
        log.info("### 获取肺炎疫情实时报告数据定时任务开始 ###");
        getData.getSituationRealTimeReportData();
        log.info("### 获取肺炎疫情实时报告数据定时任务结束 ###");
    }*/
}
